package com.bzyd.mp.customkey.controller;

import com.bzyd.mp.mapper.StudentMapper;
import com.bzyd.mp.model.po.Student;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class StudentController {

    @Autowired
    private StudentMapper studentMapper;

    @GetMapping("/insertStudent")
    public Object insertStudent(String studentNo) {
        long threadId = Thread.currentThread().getId();
        Student student = new Student();
        if (StringUtils.isNotBlank(studentNo)) {
            student.setStudentNo(studentNo);
        }
        student.setStudentName("student" + threadId);
        studentMapper.insert(student);
        return student;
    }
}
